#include <string.h>

#include "gkt_board.h"
#include "gkt_debug.h"
#include "gkt_os.h"
#include "gkt_date_time.h"
#include "gkt_gpio.h"
#include "gkt_keypad.h"
#include "gkt_rtc.h"
#include "gkt_adc.h"
#include "gkt_user.h"
#include "gkt_door.h"
#include "gkt_card.h"
#include "gkt_fpsensor.h"
#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
#include "gkt_face_id.h"
#endif
#if	defined(GKT_CONFIG_PROXIMITY_SENSOR_ENABLE) && (GKT_CONFIG_PROXIMITY_SENSOR_ENABLE)
#include "gkt_pr_sensor.h"
#endif
#include "gkt_wakeup.h"
#include "gkt_factory_reset.h"
#include "gkt_battery.h"
#if defined(GKT_CONFIG_NETWORK_ENABLE) && GKT_CONFIG_NETWORK_ENABLE
#include "gkt_network.h"
#endif
#if defined(GKT_CONFIG_CAT_EYE_ENABLE) && GKT_CONFIG_CAT_EYE_ENABLE
#include "gkt_cat_eye.h"
#endif
#if defined(GKT_CONFIG_BACKBOARD_ENABLE) && GKT_CONFIG_BACKBOARD_ENABLE
#include "gkt_backboard.h"
#endif
#include "window_common.h"
#include "window_verify.h"
#include "window_opcode.h"
#include "window_factory_inspect.h"
#include "window_hotkey.h"
//#include "gkt_gpio.h"
#if defined(GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE) && GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE
#include "window_trial.h"
#endif
#if defined(GKT_CONFIG_DOOR_VERIFY_LOCKED_ENABLE) && GKT_CONFIG_DOOR_VERIFY_LOCKED_ENABLE
#include "window_verify_locked.h"
#endif

#ifdef GKT_CONFIG_WINDOW_WELCOME_VERIFY_DISCARD_1ST_DIGIT_KEY
#define WINDOW_WELCOME_VERIFY_DISCARD_1ST_DIGIT_KEY	\
	GKT_CONFIG_WINDOW_WELCOME_VERIFY_DISCARD_1ST_DIGIT_KEY
#else
#define WINDOW_WELCOME_VERIFY_DISCARD_1ST_DIGIT_KEY	0
#endif
#define WINDOW_WELCOME_TIME_RESHOW_TIMEOUT	3000
enum {
	TIMER_ID_FACTORY_RESET_CHECK = 0,
	TIMER_ID_TIME_RESHOW,
#if defined(GKT_CONFIG_RFID_ENABLE) && GKT_CONFIG_RFID_ENABLE
	TIMER_ID_CARD_DELAY_ENABLE,
#endif
#if defined(GKT_CONFIG_DOOR_TAMPER_ENABLE) && GKT_CONFIG_DOOR_TAMPER_ENABLE
	TIMER_ID_DOOR_TAMPER_CHECK,
#endif
#if defined(GKT_CONFIG_INDOOR_BELL_ENABLE) && GKT_CONFIG_INDOOR_BELL_ENABLE
	TIMER_ID_DOOR_BELL_TIMEOUT,
#endif
#if defined(GKT_CONFIG_INTERNAL_DOORBELL_ENABLE) && GKT_CONFIG_INTERNAL_DOORBELL_ENABLE
	TIMER_ID_INTERNAL_DOORBELL_DELAY,
#endif
#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
	TIMER_ID_FACE_ID_RESTART_TIMEOUT,
	TIMER_ID_FACE_ID_SILENT_MODE_CD,
#endif
#if defined(GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE) && GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE
	TIMER_ID_PLAY_TRIAL_PLEASE_UPGRADE,
#endif
	TIMER_ID_MAX
};

#ifdef GKT_CONFIG_FACTORY_RESET_ACTIVE_TIME
#define FACTORY_RESET_ACTIVE_TIME	GKT_CONFIG_FACTORY_RESET_ACTIVE_TIME
#else
#define FACTORY_RESET_ACTIVE_TIME	5000
#endif
#define FACTORY_RESET_CHECK_UNIT	200
#define FACTORY_RESET_CHECK_COUNTER	(FACTORY_RESET_ACTIVE_TIME / FACTORY_RESET_CHECK_UNIT)
#define FACTORY_RESET_CHECK_COUNTER_1S	(1000 / FACTORY_RESET_CHECK_UNIT)

#define DOOR_TAMPER_ACTIVE_TIME	500
#define DOOR_TAMPER_CHECK_UNIT	100
#define DOOR_TAMPER_CHECK_COUNTER	(DOOR_TAMPER_ACTIVE_TIME / DOOR_TAMPER_CHECK_UNIT)

#define REMOTE_UNLOCK_TIME_OUT_MS 60*1000

#define DOOR_KEY_CHECK_UNIT 200

#if defined(GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE) && GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE
#define WINDOW_WELCOME_PLAY_TRIAL_ALARM_DURATION 1500
#define WINDOW_WELCOME_PLAY_TRIAL_ALARM_INTERVAL 200
#define WINDOW_WELCOME_PLAY_TRIAL_ALARM_TIMES 3
#define WINDOW_WELCOME_PLAY_TRIAL_PLEASE_UPGRADE_TIME (((1500+200) * 3) + 500)
#endif

/* voice type */
enum {
	WINDOW_WELCOME_VOICE_WELCOME = 0,
	WINDOW_WELCOME_VOICE_WELCOME_CARD_FINGERPRINT_WAKEUP,	
	WINDOW_WELCOME_VOICE_DOOR_BELL,
	WINDOW_WELCOME_VOICE_BATTERY_LOW,
#if defined(GKT_CONFIG_DOOR_MAGNETIC_ENABLE) && GKT_CONFIG_DOOR_MAGNETIC_ENABLE
	WINDOW_WELCOME_VOICE_DOOR_NOT_CLOSED,
#endif
#if defined(GKT_CONFIG_DOOR_TAMPER_ENABLE) && GKT_CONFIG_DOOR_TAMPER_ENABLE
	WINDOW_WELCOME_VOICE_DOOR_TEMPER,
	WINDOW_WELCOME_VOICE_DOOR_TEMPER_WAKEUP,
#endif
#if defined(GKT_CONFIG_FACTORY_INSPECT_ENABLE) && GKT_CONFIG_FACTORY_INSPECT_ENABLE
	WINDOW_WELCOME_VOICE_FACTORY_INSPECT_INCOMPLETE,
#endif
#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
	WINDOW_WELCOME_VOICE_FACE_ID_STRANGER,
#endif
#if defined(GKT_CONFIG_FACTORY_RESET_ENABLE) && GKT_CONFIG_FACTORY_RESET_ENABLE
	WINDOW_WELCOME_VOICE_FACTORY_RESET_WAKEUP,
#endif
#if defined(GKT_CONFIG_BACKBOARD_ENABLE) && GKT_CONFIG_BACKBOARD_ENABLE
	WINDOW_WELCOME_VOICE_CHECK_PAIRING,
#endif
#if defined(GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE) && GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE
	WINDOW_WELCOME_VOICE_TRIAL_PLEASE_UPGRADE,
	WINDOW_WELCOME_VOICE_TRIAL_ALARM,
#endif
	WINDOW_WELCOME_VOICE_UNKNOW_WAKEUP,
	WINDOW_WELCOME_VOICE_MAX
};

enum {
	WINDOW_WELCOME_MASK_DEFAULT = 0,
	WINDOW_WELCOME_MASK_BATTERY_LOW,
	WINDOW_WELCOME_MASK_DOOR_TAMPER,
	WINDOW_WELCOME_MASK_MAX
};

enum {
	WINDOW_WELCOME_SHOW_NORMAL = 0,
	WINDOW_WELCOME_SHOW_BATTERY_LOW,
	WINDOW_WELCOME_SHOW_MAX
};

typedef struct _window_welcome {
	gkt_wakeup_src_e	wakeup_resource;

	uint32_t	show_type;

	uint32_t	voice_playing_id;
	uint32_t	voice_pending_bits;
	int	voice_request_ids[WINDOW_WELCOME_VOICE_MAX];

#if defined(GKT_CONFIG_INDOOR_BELL_ENABLE) && GKT_CONFIG_INDOOR_BELL_ENABLE
	uint32_t	door_bell_times;
	uint32_t	door_bell_mask_bits;
#endif
#if defined(GKT_CONFIG_INTERNAL_DOORBELL_ENABLE) && GKT_CONFIG_INTERNAL_DOORBELL_ENABLE
	uint32_t 	door_bell_number;
#endif
	gkt_battery_level_e	battery_level;
	int	battery_low_showed;
	int battery_low_voice_played;
#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
	int battery_low_voice_paly_flag;
#endif

#if defined(GKT_CONFIG_FACTORY_INSPECT_ENABLE) && GKT_CONFIG_FACTORY_INSPECT_ENABLE
	int	factory_inspect_complete;
#endif

#if defined(GKT_CONFIG_RFID_ENABLE) && GKT_CONFIG_RFID_ENABLE
	gkt_card_info_s	card_info;
#if defined(GKT_CONFIG_CARD_HEADER_ENABLE) && GKT_CONFIG_CARD_HEADER_ENABLE
	uint8_t card_header[16];
#endif
#endif

#if defined(GKT_CONFIG_DOOR_TAMPER_ENABLE) && GKT_CONFIG_DOOR_TAMPER_ENABLE
	uint32_t	door_tamper_poll_counter;
#endif

	int	factory_reset_detect;
	int factory_reset_type;
	int	factory_reset_check_complete;
	int factory_reset_check_complete_voice_id;
	uint32_t	factory_reset_poll_counter;

#if defined(GKT_CONFIG_DOOR_LOCK_ENABLE) && GKT_CONFIG_DOOR_LOCK_ENABLE \
	&& defined(GKT_CONFIG_DOOR_LOCK_AUTOMATIC) && GKT_CONFIG_DOOR_LOCK_AUTOMATIC\
	&& GKT_KEY_DOUBLE_LOCK_ENABLE && GKT_KEY_DOUBLE_LOCK_MULTIPLEX
	int	double_lock_key_wait_long_press;
#endif

	window_verify_attr_u	verify_attr;
} window_welcome_s;
static window_welcome_s s_window_welcome;
#if defined(GKT_CONFIG_DOOR_LOCK_ENABLE) && GKT_CONFIG_DOOR_LOCK_ENABLE \
	&& defined(GKT_CONFIG_DOOR_LOCK_AUTOMATIC) && GKT_CONFIG_DOOR_LOCK_AUTOMATIC\
	&& GKT_KEY_DOUBLE_LOCK_ENABLE && GKT_KEY_DOUBLE_LOCK_MULTIPLEX
#define window_clear_double_lock_key_wait_long_press()	\
	do { s_window_welcome.double_lock_key_wait_long_press = 0; } while (0)
#else
#define window_clear_double_lock_key_wait_long_press()	do {} while (0)
#endif
#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
#define	WELCOME_FACE_ID_TIMEOUT_MAX 3
static uint32_t flag_operation = 0;//the human operation the lock or not
static uint32_t silence_exit_flag;
static uint32_t silence_exit_cd_cnt = 0;
static uint16_t welcome_face_id_timeout_cnt;
static uint16_t welcome_face_id_reply_type;
extern int window_verify_face_id_verify(void);
static void welcome_face_id_timeout_handle(void);
static void window_welcome_face_id_start(void);
#endif

static void window_welcome_mask(uint32_t mask_status)
{
	uint32_t mask_bit = 0;

	if(mask_status == WINDOW_WELCOME_MASK_DEFAULT) {
#if defined(GKT_CONFIG_RFID_ENABLE) && GKT_CONFIG_RFID_ENABLE
		if (g_window_ram_data.delay_unmask_card) {
			mask_bit |= 1U << GKT_EVENT_CARD;
			g_window_ram_data.delay_unmask_card_ms = 
					gkt_systime_ms() + WINDOW_DATA_DELAY_UNMASK_CARD_TIME + 100;
			gkt_window_timer_set(TIMER_ID_CARD_DELAY_ENABLE, 
					WINDOW_DATA_DELAY_UNMASK_CARD_TIME, 0, 0);
		}
#endif
		window_common_mask(mask_bit);
	}
	else if((mask_status == WINDOW_WELCOME_MASK_BATTERY_LOW)
		|| (mask_status == WINDOW_WELCOME_MASK_DOOR_TAMPER)) 
	{
		window_common_mask_all();
	}

#if !defined(GKT_CONFIG_WINDOW_VOICE_MUTE_DISABLE) \
	|| !GKT_CONFIG_WINDOW_VOICE_MUTE_DISABLE
	if (gp_window_data->voice_mute_enable)
		mask_bit = ~0;
	else
#endif
		mask_bit = (1U << GKT_KEY_ASTERISK) | (1U << GKT_KEY_BELL);
	gkt_key_voice_mask(mask_bit);
}

static void window_welcome_get_battery_level(void)
{
	gkt_battery_set_adc_adjust_value(gp_window_unreset_data->adc_adjust_value);
	s_window_welcome.battery_level = gkt_battery_get_level();
	gkt_info("window_welcome: adjust_value =%d battery_level = %u\n", 
			gp_window_unreset_data->adc_adjust_value, s_window_welcome.battery_level);
}
static void window_welcome_show(uint32_t show_type)
{
	gkt_trace("welcome: show %u --> %u ...\n",
		s_window_welcome.show_type, show_type);
	if (WINDOW_WELCOME_SHOW_NORMAL == show_type) {
	}
	else if (WINDOW_WELCOME_SHOW_BATTERY_LOW == show_type) {
		s_window_welcome.battery_low_showed = 1;

		gkt_window_timer_set(TIMER_ID_TIME_RESHOW,
				WINDOW_WELCOME_TIME_RESHOW_TIMEOUT, 0, 0);
	}
	else {
		gkt_error("welcome_show: unknown type(%u)\n",
				s_window_welcome.show_type);
		return;
	}

	s_window_welcome.show_type = show_type;
}
/************************************************************
 * welcome voice
 ************************************************************/
#define WINDOW_WELCOME_DOOR_BELL_PLAY_TIMES	2
#define WINDOW_WELCOME_DOOR_BELL_PLAY_INTERVAL	200

typedef struct _window_welcome_voice_attr {
	uint32_t	combind_id;
	uint32_t	flags;
	gkt_voice_output_playback_attr_s	params;
} window_welcome_voice_attr_s;
static const window_welcome_voice_attr_s 
	sc_window_welcome_voice_attrs[WINDOW_WELCOME_VOICE_MAX] = 
{
	[WINDOW_WELCOME_VOICE_WELCOME] = {
		.combind_id	= WINDOW_VOICE_COMBINED_ID(welcome_home),
		.flags	= GKT_WINDOW_VOICE_F_MUTE_AFFECTED,
		.params	= {
			.times	= 1,
			.interval	= 0,
		}
	},
	[WINDOW_WELCOME_VOICE_WELCOME_CARD_FINGERPRINT_WAKEUP] = {
#if defined(GKT_CONFIG_VOICE_USED_ENGLISH_SOUND)	\
	&& GKT_CONFIG_VOICE_USED_ENGLISH_SOUND
		.combind_id	= WINDOW_VOICE_COMBINED_ID(welcome_home),
#else	
		.combind_id	= WINDOW_VOICE_COMBINED_ID(welcome_home_card_fingerprint),
#endif		
		.flags	= GKT_WINDOW_VOICE_F_MUTE_AFFECTED,
		.params	= {
			.times	= 1,
			.interval	= 0,
		}
	},
#if defined(GKT_CONFIG_INDOOR_BELL_ENABLE) && GKT_CONFIG_INDOOR_BELL_ENABLE
	[WINDOW_WELCOME_VOICE_DOOR_BELL] = {
		.combind_id	= WINDOW_VOICE_COMBINED_ID(door_bell),
		.flags	= 0,
		.params	= {
			.times	= 1,//2
			.interval	= 0,//200
		}
	},
#else
	[WINDOW_WELCOME_VOICE_DOOR_BELL] = {
		.combind_id	= WINDOW_VOICE_COMBINED_ID(door_bell),
		.flags	= 0,
		.params	= {
			.times	= WINDOW_WELCOME_DOOR_BELL_PLAY_TIMES,
			.interval	= WINDOW_WELCOME_DOOR_BELL_PLAY_INTERVAL
		}
	},
#endif
	[WINDOW_WELCOME_VOICE_BATTERY_LOW] = {
		.combind_id	= WINDOW_VOICE_COMBINED_ID(lowpower),
		.flags	= GKT_WINDOW_VOICE_F_UNINTERRUPT,
		.params	= {
			.times	= 1,
			.interval	= 0,
		}
	},
#if defined(GKT_CONFIG_DOOR_MAGNETIC_ENABLE) && GKT_CONFIG_DOOR_MAGNETIC_ENABLE
	[WINDOW_WELCOME_VOICE_DOOR_NOT_CLOSED] = {
		.combind_id	= WINDOW_VOICE_COMBINED_ID(door_not_closed),
		.flags	= GKT_WINDOW_VOICE_F_FOLLOWING | GKT_WINDOW_VOICE_F_AUTO_RESTART,
		.params	= {
			.times	= ~0,
			.interval	= 3000,
		}
	},
#endif
#if defined(GKT_CONFIG_DOOR_TAMPER_ENABLE) && GKT_CONFIG_DOOR_TAMPER_ENABLE
	[WINDOW_WELCOME_VOICE_DOOR_TEMPER] = {
		.combind_id	= WINDOW_VOICE_COMBINED_ID(alarm),
		.flags	= GKT_WINDOW_VOICE_F_DETACHED | GKT_WINDOW_VOICE_F_RESIDENT 
					| GKT_WINDOW_VOICE_F_FOLLOWING | GKT_WINDOW_VOICE_F_AUTO_RESTART,
		.params	= {
			.times	= ~0,
			.interval	= 1000,
		}
	},
	[WINDOW_WELCOME_VOICE_DOOR_TEMPER_WAKEUP] = {
		.combind_id	= WINDOW_VOICE_COMBINED_ID(forbid),
		.flags	= 0,
		.params	= {
			.times	= 1,
			.interval	= 0,
		}
	},
#endif
#if defined(GKT_CONFIG_FACTORY_INSPECT_ENABLE) && GKT_CONFIG_FACTORY_INSPECT_ENABLE
	[WINDOW_WELCOME_VOICE_FACTORY_INSPECT_INCOMPLETE] = {
		.combind_id	= WINDOW_VOICE_COMBINED_ID(forbid),
		.flags	= GKT_WINDOW_VOICE_F_FOLLOWING | GKT_WINDOW_VOICE_F_AUTO_RESTART,
		.params	= {
			.times	= ~0,
			.interval	= 500,
		}
	},
#endif
#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
	[WINDOW_WELCOME_VOICE_FACE_ID_STRANGER] = {
		.combind_id	= WINDOW_VOICE_COMBINED_ID(invalid_face_id),
		.flags	= 0,
		.params	= {
			.times	= 1,
			.interval	= 0,
		}
	},
#endif
#if defined(GKT_CONFIG_FACTORY_RESET_ENABLE) && GKT_CONFIG_FACTORY_RESET_ENABLE
	[WINDOW_WELCOME_VOICE_FACTORY_RESET_WAKEUP] = {
		.combind_id	= WINDOW_VOICE_COMBINED_ID(key),
		.flags	= 0,
		.params	= {
			.times	= 1,
			.interval	= 0,
		}
	},
#endif
#if defined(GKT_CONFIG_BACKBOARD_ENABLE) && GKT_CONFIG_BACKBOARD_ENABLE
	[WINDOW_WELCOME_VOICE_CHECK_PAIRING] = {
		.combind_id	= WINDOW_VOICE_COMBINED_ID(alarm),
		.flags	= GKT_WINDOW_VOICE_F_DETACHED | GKT_WINDOW_VOICE_F_RESIDENT
					| GKT_WINDOW_VOICE_F_FOLLOWING | GKT_WINDOW_VOICE_F_AUTO_RESTART
					| GKT_WINDOW_VOICE_F_UNINTERRUPT,
		.params	= {
			.times	= ~0,
			.interval	= 500,
		}
	},
#endif
#if defined(GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE) && GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE
	[WINDOW_WELCOME_VOICE_TRIAL_PLEASE_UPGRADE] = {
		.combind_id = WINDOW_VOICE_COMBINED_ID(please_upgrade),
		.flags	= GKT_WINDOW_VOICE_F_UNINTERRUPT,
		.params = {
			.times	= 3,
			.interval	= 1000,
		}
	},
	[WINDOW_WELCOME_VOICE_TRIAL_ALARM] = {
		.combind_id	= WINDOW_VOICE_COMBINED_ID(alarm),
		.flags	= 0,
		.params	= {
			.times	= WINDOW_WELCOME_PLAY_TRIAL_ALARM_TIMES,
			.interval	= WINDOW_WELCOME_PLAY_TRIAL_ALARM_INTERVAL,
		}
	},
#endif
	[WINDOW_WELCOME_VOICE_UNKNOW_WAKEUP] = {
		.combind_id	= WINDOW_VOICE_COMBINED_ID(forbid),
		.flags	= 0,
		.params	= {
			.times	= 1,
			.interval	= 0,
		}
	},
};

#if defined(GKT_CONFIG_INDOOR_BELL_ENABLE) && GKT_CONFIG_INDOOR_BELL_ENABLE
#define WINDOW_WELCOME_DOOR_BELL_VOICE_MASK	0x01
#define WINDOW_WELCOME_DOOR_BELL_INDOOR_MASK	0x02
#define WINDOW_WELCOME_DOOR_BELL_BOTH_MASK	\
	(WINDOW_WELCOME_DOOR_BELL_VOICE_MASK | WINDOW_WELCOME_DOOR_BELL_INDOOR_MASK)
static void window_welcome_door_bell_reset(void)
{
	s_window_welcome.door_bell_times = 0;
	s_window_welcome.door_bell_mask_bits = 0;
}
static void window_welcome_play_indoor_bell(void)
{
	uint32_t timeout;
	int retval;

	retval = gkt_indoor_bell_play();
	if (GKT_SUCCESS == retval) {
		if (!s_window_welcome.door_bell_times) {
			timeout = gkt_indoor_bell_get_duration() + 500;
			gkt_window_timer_set(TIMER_ID_DOOR_BELL_TIMEOUT, timeout, 0, 0);
		}
	}
	else if (retval != GKT_EINPROCESS)
		s_window_welcome.door_bell_mask_bits |= WINDOW_WELCOME_DOOR_BELL_INDOOR_MASK;
}
#elif defined(GKT_CONFIG_INTERNAL_DOORBELL_ENABLE) && GKT_CONFIG_INTERNAL_DOORBELL_ENABLE
static void window_welcome_door_bell_reset(void)
{
	s_window_welcome.door_bell_number = 0;
}
#else
#define window_welcome_door_bell_reset()	do {} while (0)
#endif

static void window_welcome_play_voice(uint32_t id)
{
	const window_welcome_voice_attr_s *voice_attr;
	uint32_t flags;
	int retval;

	gkt_info("window_welcome: play voice %u\n", id);

	if (id < WINDOW_WELCOME_VOICE_MAX) {
		s_window_welcome.voice_pending_bits &= ~(1U << id);

		if (s_window_welcome.voice_request_ids[id] > 0) {
#if defined(GKT_CONFIG_INDOOR_BELL_ENABLE) && GKT_CONFIG_INDOOR_BELL_ENABLE
			if (WINDOW_WELCOME_VOICE_DOOR_BELL == id)
				gkt_indoor_bell_stop();
#endif
			gkt_window_voice_stop_id(s_window_welcome.voice_request_ids[id]);
			s_window_welcome.voice_request_ids[id] = -1;
		}

		voice_attr = &sc_window_welcome_voice_attrs[id];
		flags = voice_attr->flags;
		flags |= GKT_WINDOW_VOICE_F_NOTIFY_START | GKT_WINDOW_VOICE_F_NOTIFY_END;
		retval = gkt_window_voice_play(&s_window_welcome.voice_request_ids[id], 
						voice_attr->combind_id, flags, &voice_attr->params);
		if (GKT_WINDOW_VOICE_ST_PLAYING == retval) {
			s_window_welcome.voice_playing_id = id;

			if (WINDOW_WELCOME_VOICE_BATTERY_LOW == id)
				s_window_welcome.battery_low_voice_played = 1;
			else if (WINDOW_WELCOME_VOICE_DOOR_BELL == id) {
#if defined(GKT_CONFIG_INDOOR_BELL_ENABLE) && GKT_CONFIG_INDOOR_BELL_ENABLE
				window_welcome_play_indoor_bell();
#elif defined(GKT_CONFIG_INTERNAL_DOORBELL_ENABLE) && GKT_CONFIG_INTERNAL_DOORBELL_ENABLE
				gkt_gpio_config(GKT_CONFIG_INTERNAL_DOORBELL_GPIO_PIN, GKT_GPIO_F_OUTPUT | GKT_GPIO_F_OUTPUT_HIGH, NULL);
				gkt_gpio_set_pin_level(GKT_CONFIG_INTERNAL_DOORBELL_GPIO_PIN, 1);
				gkt_window_timer_set(TIMER_ID_INTERNAL_DOORBELL_DELAY, GKT_CONFIG_INTERNAL_DOORBELL_RESET_TIME_MS, 0, 0);
#endif
			}

			gkt_info("window_welcome: voice (%d) playing ...\n",
				s_window_welcome.voice_request_ids[id]);
		}
		else if (GKT_WINDOW_VOICE_ST_PENDING == retval) {
			s_window_welcome.voice_pending_bits |= 1U << id;
			gkt_info("window_welcome: voice (%d) pending ...\n", 
				s_window_welcome.voice_request_ids[id]);
		}
		else if (retval < 0) {
			s_window_welcome.voice_request_ids[id] = -1;
			gkt_info("window_welcome: voice failed %d\n", retval); 
		}
	}
}
static void window_welcome_stop_voice(uint32_t id)
{
	gkt_trace("window_welcome: stop voice %u\n", id);

	if (id < WINDOW_WELCOME_VOICE_MAX) {
		if (s_window_welcome.voice_playing_id == id)
			s_window_welcome.voice_playing_id = WINDOW_WELCOME_VOICE_MAX;

		if (s_window_welcome.voice_request_ids[id] > 0) {
			gkt_window_voice_stop_id(s_window_welcome.voice_request_ids[id]);
			s_window_welcome.voice_request_ids[id] = -1;
		}
	}
}
static void window_welcome_voice_event_handler(uint32_t minor_type,
				int request_id)
{
	uint32_t voice_id;

	gkt_info("window_welcome: voice - type(%u), request_id(%d), factory_inspect_complete(%d)\n", 
		minor_type, request_id, s_window_welcome.factory_inspect_complete);

	for (voice_id = 0; voice_id < WINDOW_WELCOME_VOICE_MAX; voice_id++) {
		if ((s_window_welcome.voice_request_ids[voice_id] > 0)
			&& request_id == s_window_welcome.voice_request_ids[voice_id])
		{
			break;
		}
	}

	if (voice_id < WINDOW_WELCOME_VOICE_MAX) {
		if (GKT_WINDOW_VOICE_EVENT_PLAY_START == minor_type) {
			gkt_trace("window_welcome: voice(%u) start ...\n", voice_id);
			if (!(s_window_welcome.voice_pending_bits & (1U << voice_id))) {
				gkt_error("window_welcome: voice(%u) not pending.\n", voice_id);
				return;
			}
			s_window_welcome.voice_playing_id = voice_id;
			s_window_welcome.voice_pending_bits &= ~(1U << voice_id);

#if defined(GKT_CONFIG_INDOOR_BELL_ENABLE) && GKT_CONFIG_INDOOR_BELL_ENABLE
			if (WINDOW_WELCOME_VOICE_DOOR_BELL == voice_id)
				window_welcome_play_indoor_bell();
#elif defined(GKT_CONFIG_INTERNAL_DOORBELL_ENABLE) && GKT_CONFIG_INTERNAL_DOORBELL_ENABLE
			if (WINDOW_WELCOME_VOICE_DOOR_BELL == voice_id) {
				if (!s_window_welcome.door_bell_number) {
					s_window_welcome.door_bell_number++;
					window_welcome_play_voice(voice_id);
				}
			}
#endif

			return;
		}

		gkt_trace("window_welcome:voice(%u) end.\n", voice_id);

#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
		if (WINDOW_WELCOME_VOICE_FACE_ID_STRANGER == voice_id) {
			gkt_window_system_standby(0);
		}
#endif

		s_window_welcome.voice_request_ids[voice_id] = -1;
		if (s_window_welcome.voice_playing_id == voice_id)
			s_window_welcome.voice_playing_id = WINDOW_WELCOME_VOICE_MAX;

#if defined(GKT_CONFIG_INDOOR_BELL_ENABLE) && GKT_CONFIG_INDOOR_BELL_ENABLE
		if (WINDOW_WELCOME_VOICE_DOOR_BELL == voice_id) {
			if (!(s_window_welcome.door_bell_mask_bits & WINDOW_WELCOME_DOOR_BELL_VOICE_MASK)) {
				s_window_welcome.door_bell_mask_bits |= WINDOW_WELCOME_DOOR_BELL_VOICE_MASK;
				if (WINDOW_WELCOME_DOOR_BELL_BOTH_MASK == s_window_welcome.door_bell_mask_bits) {
					gkt_window_timer_clear(TIMER_ID_DOOR_BELL_TIMEOUT);

					s_window_welcome.door_bell_times++;
					if (s_window_welcome.door_bell_times < WINDOW_WELCOME_DOOR_BELL_PLAY_TIMES) {
						s_window_welcome.door_bell_mask_bits = 0;
						window_welcome_play_voice(voice_id);
						return;
					}
				}
				else
					return;
			}
		}
#endif
		if (WINDOW_WELCOME_SHOW_BATTERY_LOW == s_window_welcome.show_type) {
			if (WINDOW_WELCOME_VOICE_BATTERY_LOW == voice_id) {
				gkt_window_timer_clear(TIMER_ID_TIME_RESHOW);
				window_welcome_mask(WINDOW_WELCOME_MASK_DEFAULT);
				window_welcome_show(WINDOW_WELCOME_SHOW_NORMAL);
	#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
				s_window_welcome.battery_low_voice_paly_flag = 0;
				if (gkt_face_id_is_ready())
					window_welcome_face_id_start();
	#endif
			}
			else if (!s_window_welcome.battery_low_voice_played) {
				/* reset TIME_RESHOW */
				gkt_window_timer_set(TIMER_ID_TIME_RESHOW, 
						WINDOW_WELCOME_TIME_RESHOW_TIMEOUT, 0, 0);
				window_welcome_play_voice(WINDOW_WELCOME_VOICE_BATTERY_LOW);
				return;
			}
		}
#if defined(GKT_CONFIG_FACTORY_INSPECT_ENABLE) && GKT_CONFIG_FACTORY_INSPECT_ENABLE
		if (!s_window_welcome.factory_inspect_complete)
			window_welcome_play_voice(WINDOW_WELCOME_VOICE_FACTORY_INSPECT_INCOMPLETE);
#endif
	}
}

#if defined(GKT_CONFIG_FACTORY_INSPECT_ENABLE) && GKT_CONFIG_FACTORY_INSPECT_ENABLE
static void window_welcome_check_factory_inspect_complete(void)
{
	gkt_user_amount_s amount;

	s_window_welcome.factory_inspect_complete = 1;
	if (!gp_window_unreset_data->factory_inspect_complete) {
		amount.used_nums = 0;
		gkt_user_get_amount(&amount,GKT_USER_AUTH_ADMIN, GKT_USER_TYPE_MAX);
		if (!amount.used_nums)
			s_window_welcome.factory_inspect_complete = 0;
	}

	gkt_trace("window_welcome: factory_inspect_complete(%d)\n", 
		s_window_welcome.factory_inspect_complete);
}
#else
#define window_welcome_check_factory_inspect_complete()	do {} while(0)
#endif

#if defined(GKT_CONFIG_RFID_ENABLE) && GKT_CONFIG_RFID_ENABLE
static void window_welcome_init_delay_unmask_card(void)
{
	gkt_event_mask_single(GKT_EVENT_CARD, 0);
	g_window_ram_data.delay_unmask_card = 1;
	g_window_ram_data.delay_unmask_card_ms = gkt_systime_ms() + 1000 + 100;
	gkt_window_timer_set(TIMER_ID_CARD_DELAY_ENABLE, 1000, 0, 0);
}

#ifdef GKT_CONFIG_KEYPAD_SENSITIVE_STANDBY_DELTA_ATTR_TABLE
static void window_welcome_set_keypad_parameter(int key_masked,
				uint32_t parameter_value)
{
	window_welcome_init_delay_unmask_card();

	gkt_key_parameter_update(parameter_value);
	gp_window_unreset_data->keypad_parameter_value = parameter_value;
	window_data_save();
	gkt_window_voice_play(NULL, WINDOW_VOICE_COMBINED_ID(set_success), 0, NULL);

	if (!key_masked) {
		gkt_thread_sleep(100);
		gkt_event_unmask_single(GKT_EVENT_KEY);
	}
}
#endif
static void window_welcome_open_keypad_test_print(int key_masked,
				uint32_t opcode)
{
	window_welcome_init_delay_unmask_card();

	if (WINDOW_OPCODE_COMPATIBLE_KEYPAD_OPEN_PARAMETER_TEST_PRINT == opcode)
		gkt_keypad_parameter_print_open();
	else if (WINDOW_OPCODE_COMPATIBLE_KEYPAD_OPEN_REAL_TRIM_PRINT == opcode)
		gkt_keypad_real_trim_print_open();
	gkt_window_voice_play(NULL, WINDOW_VOICE_COMBINED_ID(set_success), 0, NULL);

	if (!key_masked) {
		gkt_thread_sleep(100);
		gkt_event_unmask_single(GKT_EVENT_KEY);
	}

}
static void window_welcome_set_rfid_standby_mode(int key_masked,
				uint32_t standby_mode)
{
	window_welcome_init_delay_unmask_card();

	gkt_card_standby_mode(standby_mode);
	gp_window_unreset_data->rfid_standby_mode = standby_mode;
	window_data_save();

	if (!key_masked) {
		gkt_thread_sleep(100);
		gkt_event_unmask_single(GKT_EVENT_KEY);
	}
}
#endif

static void window_welcome_enter_verify_window(
				uint32_t mode, uint32_t user_type, uint32_t data)
{
	s_window_welcome.verify_attr.type = WINDOW_VERIFY_TYPE_UNLOCK;
	s_window_welcome.verify_attr.unlock.mode = mode;
	s_window_welcome.verify_attr.unlock.user_type = user_type;
	s_window_welcome.verify_attr.unlock.extend_data = data;

#if defined(GKT_CONFIG_RFID_ENABLE) && GKT_CONFIG_RFID_ENABLE
	gkt_user_amount_s amount;
	if (GKT_USER_TYPE_CARD == user_type) {
		uint32_t *event_data;
		int key_masked;

		event_data = (uint32_t *)data;
		gkt_card_info_s *card_info = (gkt_card_info_s *)event_data[0];
	
		memcpy(&s_window_welcome.card_info.base, &card_info->base, sizeof(gkt_rfid_info_s));
		s_window_welcome.card_info.header = NULL;
#if defined(GKT_CONFIG_CARD_HEADER_ENABLE) && GKT_CONFIG_CARD_HEADER_ENABLE
		memcpy(s_window_welcome.card_header, card_info->header, 16);
		s_window_welcome.card_info.header = s_window_welcome.card_header;
#endif

		key_masked = gkt_event_is_masked(GKT_EVENT_KEY);
		if (!key_masked)
			gkt_event_mask_single(GKT_EVENT_KEY, GKT_KEY_MASK_F_LED_DETACH);

		if (card_info->base.type == GKT_RFID_TYPE_14443A) {
#if defined(GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE) || defined(GKT_CONFIG_DOOR_VERIFY_LOCKED_ENABLE)
			int retval = GKT_EUNKNOWN;
#if GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE
			retval = window_trial_update_auth(&s_window_welcome.card_info.base);
#elif GKT_CONFIG_DOOR_VERIFY_LOCKED_ENABLE
			retval = window_verify_locked_update_status(&s_window_welcome.card_info.base);
#endif
			if (GKT_SUCCESS == retval) {
				g_window_ram_data.delay_unmask_card = 1;
				gkt_event_mask_single(GKT_EVENT_CARD, 0);

				if (!key_masked) {
					gkt_thread_sleep(100);
					gkt_event_unmask_single(GKT_EVENT_KEY);
				}

				gkt_window_voice_play(NULL, WINDOW_VOICE_COMBINED_ID(set_success), 0, NULL);

				g_window_ram_data.delay_unmask_card_ms = 
						gkt_systime_ms() + WINDOW_DATA_DELAY_UNMASK_CARD_TIME + 100;
				gkt_window_timer_set(TIMER_ID_CARD_DELAY_ENABLE, 
						WINDOW_DATA_DELAY_UNMASK_CARD_TIME, 0, 0);

				return;
			}
#endif

			amount.used_nums = 0;
			gkt_user_get_amount(&amount, GKT_USER_AUTH_ADMIN, GKT_USER_TYPE_MAX);
			gkt_info("window_welcome gkt_user_get_amount amount.used_nums=%d\n", amount.used_nums);
			if (!amount.used_nums) {
				g_window_ram_data.delay_unmask_card = 0;
				g_window_ram_data.delay_unmask_card_ms = 0;

#if defined(GKT_CONFIG_KEYPAD_SPT5115S_ENABLE) && GKT_CONFIG_KEYPAD_SPT5115S_ENABLE
				gkt_card_polling_control(0);
				gkt_keypad_control(GKT_KEYPAD_CTRL_DISABLE, 0);
				gkt_rfid_control(GKT_RFID_CTRL_ENABLE, GKT_RFID_EXT_DATA_KEY);
#endif
				uint32_t describe;
				// window initialize opcode
				describe = gkt_card_describe_fetch(&s_window_welcome.card_info.base);
#if defined(GKT_CONFIG_KEYPAD_SPT5115S_ENABLE) && GKT_CONFIG_KEYPAD_SPT5115S_ENABLE
				gkt_card_polling_control(1);				
#endif
				gkt_info("window_welcome: describe = %u\n", describe);
				if (describe) {
					if (WINDOW_OPCODE_COMPATIBLE_FACTORY_INSPECT_1901 == describe \
							|| WINDOW_OPCODE_COMPATIBLE_FACTORY_INSPECT_3791 == describe	\
							|| WINDOW_OPCODE_COMPATIBLE_FACTORY_INSPECT_1919 == describe) {
						gkt_window_show(WINDOW_ID_factory_inspect, describe);
					}
					else if (WINDOW_OPCODE_COMPATIBLE_AGING_TEST == describe)
						gkt_window_show(WINDOW_ID_aging_test, WINDOW_AGING_TEST_F_CARD_TRIGGER);
#ifdef GKT_CONFIG_KEYPAD_SENSITIVE_STANDBY_DELTA_ATTR_TABLE				
					else if (WINDOW_OPCODE_COMPATIBLE_KEYPAD_PARAMETER_STANDARD == describe) {
						if ((gp_window_unreset_data->keypad_parameter_value == GKT_KEYPAD_RESPONSE_SENSITIVITY)
							|| (gp_window_unreset_data->keypad_parameter_value == 0))
						{
							window_welcome_set_keypad_parameter(key_masked, GKT_KEYPAD_RESPONSE_STANDARD);
						}
					}
					else if (WINDOW_OPCODE_COMPATIBLE_KEYPAD_PARAMETER_SENSITIVE == describe) {
						if (gp_window_unreset_data->keypad_parameter_value != GKT_KEYPAD_RESPONSE_SENSITIVITY)
							window_welcome_set_keypad_parameter(key_masked, GKT_KEYPAD_RESPONSE_SENSITIVITY);
					}
#endif			
					else if (WINDOW_OPCODE_COMPATIBLE_RFID_STANDBY_SOFT_POWEROFF == describe) {
						if (gp_window_unreset_data->rfid_standby_mode != GKT_CARD_STANDBY_POWEROFF)
							window_welcome_set_rfid_standby_mode(key_masked, GKT_CARD_STANDBY_POWEROFF);
					}
					else if (WINDOW_OPCODE_COMPATIBLE_RFID_STANDBY_LPCD == describe) {
						if (gp_window_unreset_data->rfid_standby_mode != GKT_CARD_STANDBY_LPCD)
							window_welcome_set_rfid_standby_mode(key_masked, GKT_CARD_STANDBY_LPCD);
					}
					else if (WINDOW_OPCODE_COMPATIBLE_FAST_STANDBY == describe)
						gkt_window_system_standby(1);
					else if ((WINDOW_OPCODE_COMPATIBLE_KEYPAD_OPEN_PARAMETER_TEST_PRINT == describe)
						|| (WINDOW_OPCODE_COMPATIBLE_KEYPAD_OPEN_REAL_TRIM_PRINT == describe))
					{
						window_welcome_open_keypad_test_print(key_masked, describe);
					}
#if defined(GKT_CONFIG_DOOR_LOCK_ENABLE) && GKT_CONFIG_DOOR_LOCK_ENABLE					
#if !defined(GKT_CONFIG_DOOR_LOCK_AUTOMATIC) || !GKT_CONFIG_DOOR_LOCK_AUTOMATIC		
					else if (WINDOW_OPCODE_COMPATIBLE_MOTOR_ROTATE_DIRECTION_FORWARD == describe) {
						if (gp_window_unreset_data->lock_motor_rotate_direction != GKT_DOOR_LOCK_MOTOR_ROTATE_DIRECTION_FORWARD) {
							g_window_ram_data.delay_unmask_card = 1;
							gkt_event_mask_single(GKT_EVENT_CARD, 0);
		
							if (!key_masked) {
								gkt_thread_sleep(100);
								gkt_event_unmask_single(GKT_EVENT_KEY);
							}
						
							gp_window_unreset_data->lock_motor_rotate_direction = GKT_DOOR_LOCK_MOTOR_ROTATE_DIRECTION_FORWARD;
							gkt_door_lock_set_motor_rotate_direction(gp_window_unreset_data->lock_motor_rotate_direction);
							window_data_save();

							gkt_window_voice_play(NULL, WINDOW_VOICE_COMBINED_ID(set_success), 0, NULL);

							g_window_ram_data.delay_unmask_card_ms = 
							gkt_systime_ms() + 1000 + 100;
							gkt_window_timer_set(TIMER_ID_CARD_DELAY_ENABLE, 
								1000, 0, 0);
						}
					}
					else if (WINDOW_OPCODE_COMPATIBLE_MOTOR_ROTATE_DIRECTION_REVERSE == describe) {
						if (gp_window_unreset_data->lock_motor_rotate_direction != GKT_DOOR_LOCK_MOTOR_ROTATE_DIRECTION_REVERSE) {
							g_window_ram_data.delay_unmask_card = 1;
							gkt_event_mask_single(GKT_EVENT_CARD, 0);
		
							if (!key_masked) {
								gkt_thread_sleep(100);
								gkt_event_unmask_single(GKT_EVENT_KEY);
							}

							gp_window_unreset_data->lock_motor_rotate_direction = GKT_DOOR_LOCK_MOTOR_ROTATE_DIRECTION_REVERSE;
							gkt_door_lock_set_motor_rotate_direction(gp_window_unreset_data->lock_motor_rotate_direction);
							window_data_save();

							gkt_window_voice_play(NULL, WINDOW_VOICE_COMBINED_ID(set_success), 0, NULL);

							g_window_ram_data.delay_unmask_card_ms = 
							gkt_systime_ms() + 1000 + 100;
							gkt_window_timer_set(TIMER_ID_CARD_DELAY_ENABLE, 
								1000, 0, 0);
						}
					}
#endif
#endif					
					else
						goto open_verify;

					if (WINDOW_OPCODE_COMPATIBLE_FAST_STANDBY != describe) {
						gkt_event_mask_single(GKT_EVENT_CARD, 0);
						g_window_ram_data.delay_unmask_card = 1;
					}

					return;
				}
			}
		}

open_verify:
		gkt_event_mask_single(GKT_EVENT_CARD, 0);
		s_window_welcome.verify_attr.unlock.extend_data = 
				(uint32_t)&s_window_welcome.card_info;	
	}
#endif

	gkt_window_show(WINDOW_ID_verify, 
			(uint32_t)&s_window_welcome.verify_attr);
}

#if defined(GKT_CONFIG_DOOR_TAMPER_ENABLE) && GKT_CONFIG_DOOR_TAMPER_ENABLE
#ifdef GKT_CONFIG_WINDOW_WELCOME_DOOR_TAMPER_KEY_LED_FLICKER_BITS
#define WINDOW_WELCOME_DOOR_TAMPER_KEY_LED_FLICKER_BITS	\
	GKT_CONFIG_WINDOW_WELCOME_DOOR_TAMPER_KEY_LED_FLICKER_BITS
#else
#define WINDOW_WELCOME_DOOR_TAMPER_KEY_LED_FLICKER_BITS	\
	((1U << GKT_KEY_1) | (1U << GKT_KEY_3) | (1U << GKT_KEY_5) \
		| (1U << GKT_KEY_7) | (1U << GKT_KEY_9))
#endif

static void window_welcome_door_tamper_start_check(void)
{
	int detect;

	detect = gkt_door_tamper_is_detected();
	if (gp_window_data->door_tamper_alarm_enable
		&& detect && !g_window_ram_data.door_tamper_detect)
	{
		g_window_ram_data.door_tamper_detect = 1;
		s_window_welcome.door_tamper_poll_counter = DOOR_TAMPER_CHECK_COUNTER;
		gkt_window_timer_set(TIMER_ID_DOOR_TAMPER_CHECK,
				DOOR_TAMPER_CHECK_UNIT,
				GKT_WINDOW_TIMER_F_PERIODIC | GKT_WINDOW_TIMER_F_DETACHED,
				0);
	}
}
static void window_welcome_door_tamper_do_check(void)
{
	int detect;

	if (g_window_ram_data.door_tamper_detect
		&& s_window_welcome.door_tamper_poll_counter)
	{
		detect = gkt_door_tamper_is_detected();
		if (detect) {
			s_window_welcome.door_tamper_poll_counter--;
			if (!s_window_welcome.door_tamper_poll_counter) {
				gkt_window_timer_clear(TIMER_ID_DOOR_TAMPER_CHECK);

				gkt_window_timeout_disable("door_tamper - 1");
				window_welcome_play_voice(WINDOW_WELCOME_VOICE_DOOR_TEMPER);
				//window_common_control_key_real_trim("door_tamper", 0);
				gkt_key_led_flicker(WINDOW_WELCOME_DOOR_TAMPER_KEY_LED_FLICKER_BITS,
						GKT_KEY_LED_FLICKER_F_CYCLES_INFINITE);
				g_window_ram_data.door_tamper_alarm = 1;
#if defined(GKT_CONFIG_NETWORK_ENABLE) && GKT_CONFIG_NETWORK_ENABLE
				gkt_network_message_upload(GKT_NETWORK_MESSAGE_TYPE_TAMPER);
#endif
			}
		}
		else {
			gkt_window_timer_clear(TIMER_ID_DOOR_TAMPER_CHECK);
			g_window_ram_data.door_tamper_detect = 0;
			s_window_welcome.door_tamper_poll_counter = 0;
		}
	}
}
static void window_welcome_door_tamper_stop(void)
{
	if (g_window_ram_data.door_tamper_detect) {
		g_window_ram_data.door_tamper_detect = 0;

		if (s_window_welcome.door_tamper_poll_counter) {
			gkt_window_timer_clear(TIMER_ID_DOOR_TAMPER_CHECK);
			s_window_welcome.door_tamper_poll_counter = 0;
		}

		if (g_window_ram_data.door_tamper_alarm) {
			g_window_ram_data.door_tamper_alarm = 0;
			gkt_key_led_flicker(0, 0);
			//window_common_control_key_real_trim("door_tamper", 1);
			window_welcome_stop_voice(WINDOW_WELCOME_VOICE_DOOR_TEMPER);
			gkt_window_timeout_enable("door_tamper - 0");
		}
	}
}
#else
#define window_welcome_door_tamper_stop()	do {} while (0)
#endif

#if defined(GKT_CONFIG_FACTORY_RESET_ENABLE) && GKT_CONFIG_FACTORY_RESET_ENABLE
#if GKT_DOOR_KEY_COMBINED_FACTORY_RESET_ENABLE
static int window_welcome_factory_reset_is_detected(uint32_t type)
{
	return (GKT_FACTORY_RESET_TYPE_COMBINED == type) ?
			gkt_door_key_is_detected(GKT_DOOR_KEY_COMBINED_FACTORY_RESET) :
			gkt_factory_reset_is_detected();
}
#else
#define window_welcome_factory_reset_is_detected(type)	\
	gkt_factory_reset_is_detected()
#endif

static void window_welcome_factory_reset_start_check(int type)
{
	int detect;

	detect = window_welcome_factory_reset_is_detected(type);
	if (detect && !s_window_welcome.factory_reset_detect) {
		s_window_welcome.factory_reset_detect = 1;
		s_window_welcome.factory_reset_type = type;
		s_window_welcome.factory_reset_check_complete = 0;
		s_window_welcome.factory_reset_check_complete_voice_id = -1;
		s_window_welcome.factory_reset_poll_counter = FACTORY_RESET_CHECK_COUNTER;

		gkt_window_timer_set(TIMER_ID_FACTORY_RESET_CHECK,
				FACTORY_RESET_CHECK_UNIT,
				GKT_WINDOW_TIMER_F_PERIODIC | GKT_WINDOW_TIMER_F_DETACHED,
				0);

		window_welcome_door_tamper_stop();
	}
}
static void window_welcome_factory_reset_release(void)
{
	int force;

	gkt_window_timer_clear(TIMER_ID_FACTORY_RESET_CHECK);

	if (s_window_welcome.factory_reset_detect) {
		s_window_welcome.factory_reset_detect = 0;

		if (s_window_welcome.factory_reset_check_complete) {
			s_window_welcome.factory_reset_check_complete = 0;

			if (s_window_welcome.factory_reset_check_complete_voice_id > 0) {
				gkt_window_voice_stop_id(s_window_welcome.factory_reset_check_complete_voice_id);
				s_window_welcome.factory_reset_check_complete_voice_id = -1;
			}

			force = (GKT_FACTORY_RESET_TYPE_INDIVIDUAL == s_window_welcome.factory_reset_type) ? 1 : 0;
			gkt_window_show(WINDOW_ID_factory_reset, force);
		}
	}
}
static void window_welcome_factory_reset_do_check(void)
{
	gkt_voice_output_playback_attr_s voice_attr;
	uint32_t remainder;
	int detect;

	if (s_window_welcome.factory_reset_detect) {
		detect = window_welcome_factory_reset_is_detected(
						s_window_welcome.factory_reset_type);
		if (detect) {
			if (!s_window_welcome.factory_reset_poll_counter)
				return;

			s_window_welcome.factory_reset_poll_counter--;
			if (s_window_welcome.factory_reset_poll_counter > 0) {
				remainder = s_window_welcome.factory_reset_poll_counter 
								% FACTORY_RESET_CHECK_COUNTER_1S;
				if (!remainder) {
					gkt_window_voice_play(NULL, WINDOW_VOICE_COMBINED_ID(key), 
							0, NULL);
				}
			}
			else if (!s_window_welcome.factory_reset_check_complete) {
				s_window_welcome.factory_reset_check_complete = 1;

				voice_attr.times = ~0;
				voice_attr.interval = 3000;
				gkt_window_voice_play(&s_window_welcome.factory_reset_check_complete_voice_id, 
						WINDOW_VOICE_COMBINED_ID(please_uplift),
						GKT_WINDOW_VOICE_F_RESIDENT | GKT_WINDOW_VOICE_F_AUTO_RESTART, 
						&voice_attr);
			}
		}
		else
			window_welcome_factory_reset_release();
	}
}
#endif

#if defined(GKT_CONFIG_NETWORK_ENABLE) && GKT_CONFIG_NETWORK_ENABLE
static void window_welcome_remote_unlock_request(void)
{
	int retval;
	//if (!g_window_ram_data.wait_remote_unlock_response)
	{
		retval = gkt_network_remote_unlock_request(1);
		if ((GKT_EINPROCESS == retval) || (GKT_SUCCESS == retval)) {
			g_window_retmem_data.wait_remote_unlock_response = 1;
		}
	}
}
#else
#define window_welcome_remote_unlock_request()	do {} while (0)
#endif

static int window_welcome_key_event_handler(uint32_t minor_type, uint32_t *evt_data)
{
	gkt_user_amount_s amount;

#if defined(GKT_CONFIG_RFID_ENABLE) && GKT_CONFIG_RFID_ENABLE
	if (__UNLIKELY(g_window_ram_data.delay_unmask_card))
		return GKT_EVENT_HANDLE_CONTINUE;
#endif

#if defined(GKT_CONFIG_DOOR_LOCK_ENABLE) && GKT_CONFIG_DOOR_LOCK_ENABLE \
	&& defined(GKT_CONFIG_DOOR_LOCK_AUTOMATIC) && GKT_CONFIG_DOOR_LOCK_AUTOMATIC \
	&& GKT_KEY_DOUBLE_LOCK_ENABLE
	if ((GKT_KEY_DOUBLE_LOCK == minor_type)
		&& window_door_lock_body_is_normal())
	{
#if GKT_KEY_DOUBLE_LOCK_MULTIPLEX
		uint32_t key_action = evt_data[GKT_KEY_EVTDATA_ACTION];

		if ((GKT_KEY_ACTION_LONG_PRESS == key_action)
			&& s_window_welcome.double_lock_key_wait_long_press)
		{
			s_window_welcome.double_lock_key_wait_long_press = 0;
#if defined(GKT_CONFIG_AMBIENT_LIGHT_ENABLE) && GKT_CONFIG_AMBIENT_LIGHT_ENABLE
			gkt_ambient_light_set_state(WINDOW_AMBIENT_LIGHT_STATE_DEFAULT, 0, 0);
#endif
			gkt_window_show(WINDOW_ID_key_double_lock, 0);
			return GKT_EVENT_HANDLE_COMPLETE;
		}
		else if (GKT_KEY_ACTION_SHORT_PRESS == key_action) {
			s_window_welcome.double_lock_key_wait_long_press = 1;
			return GKT_EVENT_HANDLE_COMPLETE;
		}
		else if (GKT_KEY_ACTION_RELEASE == key_action)
			s_window_welcome.double_lock_key_wait_long_press = 0;
#else
		return GKT_EVENT_HANDLE_CONTINUE;
#endif
	}
#endif

	if ((minor_type >= GKT_KEY_0) && (minor_type <= GKT_KEY_9)) {
#if !WINDOW_WELCOME_VERIFY_DISCARD_1ST_DIGIT_KEY
	#if defined (GKT_CONFIG_KEYPAD_ENABLE) && GKT_CONFIG_KEYPAD_ENABLE
		gkt_key_stage(minor_type, (uint32_t)evt_data);
		window_welcome_enter_verify_window(WINDOW_VERIFY_UNLOCK_MODE_USER,
				GKT_USER_TYPE_PASSWORD, 0);
	#endif
#else
		window_welcome_enter_verify_window(WINDOW_VERIFY_UNLOCK_MODE_USER,
				GKT_USER_TYPE_MAX, 0);
#endif
	}
	else if (GKT_KEY_BELL == minor_type) {
#if defined(GKT_CONFIG_CAT_EYE_ENABLE) && GKT_CONFIG_CAT_EYE_ENABLE
		gkt_cat_eye_status_e cat_eye_status;

		cat_eye_status = gkt_cat_eye_get_status();
		gkt_info("indow_welcome: <KEY_BELL> cat_eye status(%u)\n", cat_eye_status);
		if (GKT_CAT_EYE_ST_INACTIVE == cat_eye_status)
			gkt_cat_eye_start();
		else if (GKT_CAT_EYE_ST_ACTIVE == cat_eye_status)
			window_welcome_remote_unlock_request();
#endif

		window_welcome_door_bell_reset();
		window_welcome_play_voice(WINDOW_WELCOME_VOICE_DOOR_BELL);
	}
	else if (GKT_KEY_ASTERISK == minor_type) {
		gkt_user_get_amount(&amount, GKT_USER_AUTH_ADMIN, GKT_USER_TYPE_MAX);
		if (amount.used_nums) {
			/* show verify window (login main menu) */
			s_window_welcome.verify_attr.type = WINDOW_VERIFY_TYPE_LOGIN;
			s_window_welcome.verify_attr.login.action = WINDOW_VERIFY_LOGIN_ACTION_SHOW_MAIN_MENU;
			gkt_window_show(WINDOW_ID_verify, (uint32_t)&s_window_welcome.verify_attr);
		}
		else
			gkt_window_show(WINDOW_ID_initialization, 0);
	}

	return GKT_EVENT_HANDLE_COMPLETE;
}

static void window_welcome_timer_event_handler(uint32_t timer_id)
{
	if (TIMER_ID_TIME_RESHOW == timer_id) {
			if (WINDOW_WELCOME_SHOW_BATTERY_LOW == s_window_welcome.show_type) {
				window_welcome_mask(WINDOW_WELCOME_MASK_DEFAULT);
				window_welcome_show(WINDOW_WELCOME_SHOW_NORMAL);
			}
	}
#if (defined(GKT_CONFIG_FACTORY_RESET_ENABLE) && GKT_CONFIG_FACTORY_RESET_ENABLE)
	else if (TIMER_ID_FACTORY_RESET_CHECK == timer_id)
		window_welcome_factory_reset_do_check();
#endif
#if defined(GKT_CONFIG_INTERNAL_DOORBELL_ENABLE) && GKT_CONFIG_INTERNAL_DOORBELL_ENABLE
	else if (TIMER_ID_INTERNAL_DOORBELL_DELAY == timer_id) {
		gkt_gpio_set_pin_level(GKT_CONFIG_INTERNAL_DOORBELL_GPIO_PIN, 0);
		if (s_window_welcome.door_bell_number)
			gkt_gpio_config(GKT_CONFIG_INTERNAL_DOORBELL_GPIO_PIN, GKT_GPIO_F_INPUT | GKT_GPIO_F_INPUT_PULL_DOWN, NULL);
	}
#endif
#if defined(GKT_CONFIG_DOOR_TAMPER_ENABLE) && GKT_CONFIG_DOOR_TAMPER_ENABLE
	else if (TIMER_ID_DOOR_TAMPER_CHECK == timer_id)
		window_welcome_door_tamper_do_check();
#endif
#if defined(GKT_CONFIG_RFID_ENABLE) && GKT_CONFIG_RFID_ENABLE
	else if (TIMER_ID_CARD_DELAY_ENABLE == timer_id) {
		g_window_ram_data.delay_unmask_card = 0;
		g_window_ram_data.delay_unmask_card_ms = 0;
		gkt_event_unmask_single(GKT_EVENT_CARD);
	}
#endif
#if defined(GKT_CONFIG_INDOOR_BELL_ENABLE) && GKT_CONFIG_INDOOR_BELL_ENABLE
	else if (TIMER_ID_DOOR_BELL_TIMEOUT == timer_id) {
		s_window_welcome.door_bell_times++;
		s_window_welcome.door_bell_mask_bits = 0;
		window_welcome_play_voice(WINDOW_WELCOME_VOICE_DOOR_BELL);
	}
#endif
#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
	else if (TIMER_ID_FACE_ID_RESTART_TIMEOUT == timer_id) {
		welcome_face_id_timeout_handle();
	}
	else if (TIMER_ID_FACE_ID_SILENT_MODE_CD == timer_id) {
		//window_welcome_show_silent_cd(WINDOW_WELCOME_SILENT_CD_CD);
	}
#endif
#if defined(GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE) && GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE
	else if (TIMER_ID_PLAY_TRIAL_PLEASE_UPGRADE == minor_type)
		window_welcome_play_voice(WINDOW_WELCOME_VOICE_TRIAL_PLEASE_UPGRADE);
#endif
}

static void window_welcome_system_event_handler(
				uint32_t minor_type, uint32_t type, uint32_t data)
{
	if (GKT_WINDOW_SYSTEM_DOOR == minor_type) {
#if (GKT_MODULE_LOC_BACKBOARD == GKT_DOOR_LOCK_LOCATION) \
	&& (defined(GKT_CONFIG_DOOR_LOCK_AUTOMATIC) && GKT_CONFIG_DOOR_LOCK_AUTOMATIC)
		if (GKT_DOOR_NOTIFY_LOCK_STATUS == type) {
			if (GKT_DOOR_LOCK_ST_DL_CLOSED == data ||
				GKT_DOOR_LOCK_ST_CLOSED == data)
			{
#if defined(GKT_CONFIG_AMBIENT_LIGHT_ENABLE) && GKT_CONFIG_AMBIENT_LIGHT_ENABLE
				gkt_ambient_light_set_state(WINDOW_AMBIENT_LIGHT_STATE_DEFAULT, 0, 0);
#endif
				gkt_window_show(WINDOW_ID_key_double_lock, GKT_DOOR_KEY_ONLY_NOTIFY_CLOSED_STATUS);
				return;
			}
			else if (GKT_DOOR_LOCK_ST_OPENED == data)  {
#if defined(GKT_CONFIG_AMBIENT_LIGHT_ENABLE) && GKT_CONFIG_AMBIENT_LIGHT_ENABLE
#if defined(GKT_CONFIG_AMBIENT_LIGHT_FLICKER_ENABLE) && GKT_CONFIG_AMBIENT_LIGHT_FLICKER_ENABLE
				gkt_ambient_light_set_state(WINDOW_AMBIENT_LIGHT_STATE_VERIFY_OK, 100, 11);
#else
				gkt_ambient_light_set_state(WINDOW_AMBIENT_LIGHT_STATE_VERIFY_OK, 0, 0);
#endif
#endif
				gkt_window_show(WINDOW_ID_key_open_lock, 0);
				return;
			}
		}
#endif
#if defined(GKT_CONFIG_DOOR_MAGNETIC_ENABLE) && GKT_CONFIG_DOOR_MAGNETIC_ENABLE
		if (GKT_DOOR_NOTIFY_MAGNETIC == type) {
			if (data)
				window_welcome_play_voice(WINDOW_WELCOME_VOICE_DOOR_NOT_CLOSED);
			else
				window_welcome_stop_voice(WINDOW_WELCOME_VOICE_DOOR_NOT_CLOSED);
			return;
		}
#endif
#if defined(GKT_CONFIG_DOOR_TAMPER_ENABLE) && GKT_CONFIG_DOOR_TAMPER_ENABLE
		if (GKT_DOOR_NOTIFY_TAMPER == type) {
			if (data)
				window_welcome_door_tamper_start_check();
			else
				window_welcome_door_tamper_stop();
			return;
		}
#endif
#if defined(GKT_CONFIG_DOOR_KEY_ENABLE) && GKT_CONFIG_DOOR_KEY_ENABLE
		if (GKT_DOOR_NOTIFY_KEY == type) {
			if (GKT_DOOR_KEY_OPEN == data) {
				window_welcome_enter_verify_window(WINDOW_VERIFY_UNLOCK_MODE_KEY,
							GKT_USER_TYPE_MAX, 0);
			}
#if defined(GKT_CONFIG_DOOR_LOCK_AUTOMATIC) && GKT_CONFIG_DOOR_LOCK_AUTOMATIC
			else if (GKT_DOOR_KEY_DOUBLE_LOCK == data) {
#if defined(GKT_CONFIG_AMBIENT_LIGHT_ENABLE) && GKT_CONFIG_AMBIENT_LIGHT_ENABLE
				gkt_ambient_light_set_state(WINDOW_AMBIENT_LIGHT_STATE_DEFAULT, 0, 0);
#endif
				gkt_window_show(WINDOW_ID_key_double_lock, 0);
			}
#endif
#if GKT_DOOR_KEY_COMBINED_FACTORY_RESET_ENABLE
			else if (GKT_DOOR_KEY_COMBINED_FACTORY_RESET == data)
				window_welcome_factory_reset_start_check(GKT_FACTORY_RESET_TYPE_COMBINED);
#endif
		}
#endif
		gkt_unused(window_welcome_stop_voice);
	}
#if defined(GKT_CONFIG_BACKBOARD_ENABLE) && GKT_CONFIG_BACKBOARD_ENABLE
	else if (GKT_WINDOW_SYSTEM_BACKBOARD == minor_type) {
		gkt_info("window_welcome: check priring (type - data) (%d - %d)\n", type, data);
		if (GKT_BACKBAORD_COMMON_NOTIFY_TYPE_STATUS == type) {
			if (GKT_BACKBAORD_COMMON_STATUS_CHECK_PAIRING_FAILED == data) {
				window_welcome_play_voice(WINDOW_WELCOME_VOICE_CHECK_PAIRING);
				window_common_mask_all();
			}
		}
	}
#endif
#if defined(GKT_CONFIG_FACTORY_RESET_ENABLE) && GKT_CONFIG_FACTORY_RESET_ENABLE
	else if (GKT_WINDOW_SYSTEM_FACTORY_RESET == minor_type) {
		if (data)
			window_welcome_factory_reset_start_check(type);
		else {
			s_window_welcome.factory_reset_check_complete = 0;
			window_welcome_factory_reset_release();
		}
	}
#endif
#if defined(GKT_CONFIG_CAT_EYE_ENABLE) && GKT_CONFIG_CAT_EYE_ENABLE
	else if (GKT_WINDOW_SYSTEM_CAT_EYE == minor_type) {
		if (GKT_CAT_EYE_ST_ACTIVE == data)
			window_welcome_remote_unlock_request();
	}
#endif
#if defined(GKT_CONFIG_INDOOR_BELL_ENABLE) && GKT_CONFIG_INDOOR_BELL_ENABLE
	else if (GKT_WINDOW_SYSTEM_INDOOR_BELL == minor_type) {
		if (!(s_window_welcome.door_bell_mask_bits & WINDOW_WELCOME_DOOR_BELL_INDOOR_MASK)) {
			s_window_welcome.door_bell_mask_bits |= WINDOW_WELCOME_DOOR_BELL_INDOOR_MASK;
			if (WINDOW_WELCOME_DOOR_BELL_BOTH_MASK == s_window_welcome.door_bell_mask_bits) {
				gkt_window_timer_clear(TIMER_ID_DOOR_BELL_TIMEOUT);

				s_window_welcome.door_bell_times++;
				if (s_window_welcome.door_bell_times < WINDOW_WELCOME_DOOR_BELL_PLAY_TIMES) {
					s_window_welcome.door_bell_mask_bits = 0;
					window_welcome_play_voice(WINDOW_WELCOME_VOICE_DOOR_BELL);
				}
			}
		}
	}
#endif
#if (defined(GKT_CONFIG_NETWORK_ENABLE) && GKT_CONFIG_NETWORK_ENABLE)
	else if (GKT_WINDOW_SYSTEM_NETWORK == minor_type) {
		if (GKT_NETWORK_NOTIFY_TYPE_REMOTE_UNLOCK == type) {
			if (g_window_retmem_data.wait_remote_unlock_response) {
				g_window_retmem_data.wait_remote_unlock_response = 0;
				window_welcome_enter_verify_window(WINDOW_VERIFY_UNLOCK_MODE_REMOTE,
						GKT_USER_TYPE_MAX, data);
			}
		}
	}
#endif
}

#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
#if	defined(GKT_CONFIG_LIGHTING_EFFECT_EN)&&(GKT_CONFIG_LIGHTING_EFFECT_EN)
#include "gkt_lighting_effect.h"
static gkt_lighting_effect_s key_open_lock_lighting_effect;
#endif

#if	defined(GKT_CONFIG_PROXIMITY_SENSOR_ENABLE) && (GKT_CONFIG_PROXIMITY_SENSOR_ENABLE)
static void welcome_pr_sensor_wake_up_handle(void)
{
	gkt_date_time_s dts_current;
	uint32_t wake_up_time;	/* default */
	int retval;

	retval = gkt_rtc_get_time(&dts_current);
	if (GKT_SUCCESS == retval) {
		wake_up_time = GKT_DTS_2_DTU(dts_current);
		if(wake_up_time < g_window_retmem_data.pr_power_clear_dtu){
			g_window_retmem_data.pr_power_cnt++;
			if(g_window_retmem_data.pr_power_cnt > PR_SENSOR_POWER_OFF_CNT_MAX){
				g_window_retmem_data.pr_power_state = SENSE_PR_POWER_OFF;
				g_window_retmem_data.pr_power_cnt = 0;
				g_window_retmem_data.pr_power_clear_dtu = 0;
				if(gp_window_data->pr_sensor_state != SENSE_SHUTDOWN){
					gkt_pr_sensor_set_threshold(SENSE_SHUTDOWN);
				}
			}
		}
		else{
			g_window_retmem_data.pr_power_cnt = 0;
		}
		gkt_dt_add_seconds(&dts_current, PR_SENSOR_POWER_OFF_TIME_S);
		g_window_retmem_data.pr_power_clear_dtu = GKT_DTS_2_DTU(dts_current);
	}
}
#endif
#if defined(GKT_CONFIG_NETWORK_ENABLE) && GKT_CONFIG_NETWORK_ENABLE
#define FACE_ID_NOMATCH_CNT_MAX	5
#define FACE_ID_NOMATCH_TIME_S	60
static void welcome_face_id_nomatch_handle(void)
{
	gkt_date_time_s dts_current;
	uint32_t wake_up_time;	/* default */
	int retval;

	retval = gkt_rtc_get_time(&dts_current);
	if (GKT_SUCCESS == retval) {
		wake_up_time = GKT_DTS_2_DTU(dts_current);
		if(wake_up_time < g_window_retmem_data.face_id_nomatch_clear_dtu){
			g_window_retmem_data.face_id_nomatch_cnt++;
			if(g_window_retmem_data.face_id_nomatch_cnt > FACE_ID_NOMATCH_CNT_MAX){
				g_window_retmem_data.face_id_nomatch_cnt = 0;
				g_window_retmem_data.face_id_nomatch_clear_dtu = 0;
				gkt_network_message_upload(GKT_NETWORK_MESSAGE_TYPE_ALARM_STRANGER_STAY);
			}
		}
		else{
			g_window_retmem_data.face_id_nomatch_cnt = 0;
		}
		gkt_dt_add_seconds(&dts_current, FACE_ID_NOMATCH_TIME_S);
		g_window_retmem_data.face_id_nomatch_clear_dtu = GKT_DTS_2_DTU(dts_current);
	}
}
#endif
static void window_welcome_face_id_start(void)
{
	int retval;
	retval = window_verify_face_id_verify();
	if (retval == GKT_SUCCESS) {
		welcome_face_id_timeout_cnt = 0;
		welcome_face_id_reply_type = GKT_FACE_ID_MAX;
		gkt_window_timer_set(TIMER_ID_FACE_ID_RESTART_TIMEOUT,
				1000, GKT_WINDOW_TIMER_F_PERIODIC, 0);
	}
	else {
		gkt_window_timer_clear(TIMER_ID_FACE_ID_RESTART_TIMEOUT);
	}
}

static void welcome_face_id_timeout_handle(void)
{
	static int32_t err_retry=3;

	switch(welcome_face_id_reply_type){
		case GKT_FACE_ID_REPLY:
			welcome_face_id_reply_type = GKT_FACE_ID_MAX;
			welcome_face_id_timeout_cnt = 0;
			gkt_window_timer_clear(TIMER_ID_FACE_ID_RESTART_TIMEOUT);
		break;
		case GKT_FACE_ID_NOTE:
			welcome_face_id_reply_type = GKT_FACE_ID_MAX;
			welcome_face_id_timeout_cnt = 0;
		break;
		default:
			welcome_face_id_timeout_cnt++;
			if(welcome_face_id_timeout_cnt >= WELCOME_FACE_ID_TIMEOUT_MAX){
				welcome_face_id_timeout_cnt = 0;
				if(err_retry > 0){
					err_retry--;
					window_welcome_face_id_start();
				}
				else{
					gkt_window_timer_clear(TIMER_ID_FACE_ID_RESTART_TIMEOUT);
				}
			}
		break;
	}
}

static void welcome_face_id_reply_handle(uint32_t data)
{
	gkt_event_s event;
	uint32_t *event_data;
	int retval;

	if (g_window_ram_data.face_id_init_state == WINDOW_DATA_FACE_ID_STATE_SET){
		event_data = (uint32_t *)data;
		retval = gkt_face_id_result_transformation(event_data[GKT_WINDOW_USER_EVTDATA_RESULT]);
		if (GKT_SUCCESS == retval) {
			welcome_face_id_reply_type = GKT_FACE_ID_REPLY;
			event.major_type = GKT_EVENT_FACE_ID;
			event.minor_type = 0;
			event.window_id = WINDOW_ID_verify;
			event.data[GKT_WINDOW_USER_EVTDATA_RESULT] = event_data[GKT_WINDOW_USER_EVTDATA_RESULT];
			event.data[GKT_WINDOW_USER_EVTDATA_DATA] = event_data[GKT_WINDOW_USER_EVTDATA_DATA];
			gkt_event_stage(&event);
			window_welcome_enter_verify_window(WINDOW_VERIFY_UNLOCK_MODE_USER,
				GKT_USER_TYPE_FACE_ID,0);
		}
		else if(GKT_ENOMATCHED == retval){//verify fail , voice stranger detect
#if defined(GKT_CONFIG_NETWORK_ENABLE) && GKT_CONFIG_NETWORK_ENABLE
			welcome_face_id_nomatch_handle();
#endif
			welcome_face_id_reply_type = GKT_FACE_ID_REPLY;
			window_welcome_play_voice(WINDOW_WELCOME_VOICE_FACE_ID_STRANGER);
		}
		else{//GKT_EUNAVAILABLE
			if(flag_operation == 0){//not operation
#if	defined(GKT_CONFIG_PROXIMITY_SENSOR_ENABLE) && (GKT_CONFIG_PROXIMITY_SENSOR_ENABLE)
				welcome_pr_sensor_wake_up_handle();
#endif
				if(g_window_ram_data.face_id_demomode_state != WINDOW_DATA_FACE_ID_STATE_SET)
					gkt_window_system_standby(0);
			}
		}
	}
	else{//not init
		welcome_face_id_reply_type = GKT_FACE_ID_REPLY;
		gkt_trace("face_id not init\n");
		//no user,face_id return GKT_ENOMATCHED immediately without note message
	}
}

static void welcome_face_id_note_handle(uint32_t data)
{
	//voice
	gkt_trace("__face_id_ note voice\n");
}

static void window_welcome_face_id_handle(uint32_t data)
{
	uint32_t reply_type;
	uint32_t *event_data;

	event_data = (uint32_t *)data;
	if(event_data == NULL)
		return;
	reply_type = gkt_face_id_get_reply_type(event_data[GKT_WINDOW_USER_EVTDATA_DATA],MID_VERIFY);
	switch(reply_type){
		case	GKT_FACE_ID_REPLY:
			welcome_face_id_reply_type = GKT_FACE_ID_NOTE;
			welcome_face_id_reply_handle(data);
		break;
		case	GKT_FACE_ID_NOTE:
			welcome_face_id_reply_type = GKT_FACE_ID_NOTE;
			welcome_face_id_note_handle(data);
		break;
		case	GKT_FACE_ID_READY_REPLY:
			if(s_window_welcome.battery_low_voice_paly_flag == 0)
				window_welcome_face_id_start();
		break;
		default:

		break;
	}
}
#endif

#if defined(GKT_CONFIG_FPS_ENABLE) && GKT_CONFIG_FPS_ENABLE
extern int	fps_capture_retval_global;
#endif
extern uint8_t g_card_calibrate_over;
static void window_welcome_window_event_handler(uint32_t minor_type,
				uint32_t id, uint32_t data)
{
	uint32_t i;

	if (GKT_WINDOW_INIT == minor_type) {
		s_window_welcome.show_type = WINDOW_WELCOME_SHOW_MAX;
		s_window_welcome.voice_playing_id = WINDOW_WELCOME_VOICE_MAX;
		for (i = 0; i < WINDOW_WELCOME_VOICE_MAX; i++)
			s_window_welcome.voice_request_ids[i] = -1;

		s_window_welcome.wakeup_resource = gkt_wakeup_get_source();
		gkt_printf("window_welcome: wakeup_source = %u\n",
				s_window_welcome.wakeup_resource);

#if defined(GKT_CONFIG_RFID_ENABLE) && GKT_CONFIG_RFID_ENABLE
		g_window_ram_data.delay_unmask_card = 0;
		g_window_ram_data.delay_unmask_card_ms = 0;
		if (gp_window_unreset_data->rfid_standby_mode == GKT_RFID_STANBY_NONE) {
			gp_window_unreset_data->rfid_standby_mode = RFID_STANDBY_MODE;
			window_data_save();
		}
		gkt_card_standby_mode(gp_window_unreset_data->rfid_standby_mode);
#endif

#if defined(GKT_CONFIG_DOOR_TAMPER_ENABLE) && GKT_CONFIG_DOOR_TAMPER_ENABLE
		g_window_ram_data.door_tamper_detect = 0;
		g_window_ram_data.door_tamper_alarm = 0;
#endif
#if defined(GKT_CONFIG_RFID_ENABLE) && GKT_CONFIG_RFID_ENABLE
		if (g_card_calibrate_over == 1)
			gkt_keypad_control(GKT_KEYPAD_CTRL_REAL_TRIM, GKT_KEYPAD_REAL_TRIM_ENABLE);
		else
			gkt_card_open_keypad_trim();
#else
		gkt_keypad_control(GKT_KEYPAD_CTRL_REAL_TRIM, GKT_KEYPAD_REAL_TRIM_ENABLE);
#endif
		window_welcome_get_battery_level();

	}
	else if (GKT_WINDOW_ACTIVE == minor_type) {
		uint32_t mask_type, show_type, voice_id;

#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
		if((s_window_welcome.wakeup_resource != GKT_WAKEUP_SRC_none) || (!data)){
			gkt_trace("wakeup_resource = %d,data=%x,\n",s_window_welcome.wakeup_resource,data);
			flag_operation = 1;
		}
#endif
			window_welcome_check_factory_inspect_complete();

		mask_type = WINDOW_WELCOME_MASK_DEFAULT;
		show_type = WINDOW_WELCOME_SHOW_NORMAL;
		if (data) { /* 1st active */
			if (s_window_welcome.battery_level > GKT_BATTERY_LEVEL_EMPTY) {
				if (GKT_SYSTEM_RESET_WAKEUP == g_system_info.reset_mode) {
					if ((s_window_welcome.wakeup_resource == GKT_WAKEUP_SRC_keypad)
						|| (s_window_welcome.wakeup_resource == GKT_WAKEUP_SRC_sliding_closure))
						voice_id = WINDOW_WELCOME_VOICE_WELCOME;
					else if ((s_window_welcome.wakeup_resource == GKT_WAKEUP_SRC_fpsensor)
						|| (s_window_welcome.wakeup_resource == GKT_WAKEUP_SRC_rfid))
						voice_id = WINDOW_WELCOME_VOICE_WELCOME_CARD_FINGERPRINT_WAKEUP;
#if defined(GKT_CONFIG_FACTORY_RESET_ENABLE) && GKT_CONFIG_FACTORY_RESET_ENABLE
					else if (s_window_welcome.wakeup_resource == GKT_WAKEUP_SRC_factory_reset)
						voice_id = WINDOW_WELCOME_VOICE_FACTORY_RESET_WAKEUP;
#endif
#if defined(GKT_CONFIG_DOOR_TAMPER_ENABLE) && GKT_CONFIG_DOOR_TAMPER_ENABLE						
					else if ((s_window_welcome.wakeup_resource == GKT_WAKEUP_SRC_door_tamper)
						|| (s_window_welcome.wakeup_resource == GKT_WAKEUP_SRC_door_magnetic))
						voice_id = WINDOW_WELCOME_VOICE_DOOR_TEMPER_WAKEUP;
#endif
					else {
#if defined(GKT_CONFIG_DOOR_LOCK_AUTOMATIC) && GKT_CONFIG_DOOR_LOCK_AUTOMATIC
						voice_id = WINDOW_WELCOME_VOICE_MAX;
#else
						voice_id = WINDOW_WELCOME_VOICE_UNKNOW_WAKEUP;
#endif
#if	defined(GKT_CONFIG_PROXIMITY_SENSOR_ENABLE) && (GKT_CONFIG_PROXIMITY_SENSOR_ENABLE)
						if (gkt_pr_sensor_is_wakeup())
							voice_id = WINDOW_WELCOME_VOICE_MAX;
#endif
					}
				}
				else
					voice_id = WINDOW_WELCOME_VOICE_WELCOME;
			}
			else {
				mask_type = WINDOW_WELCOME_MASK_BATTERY_LOW;
				show_type = WINDOW_WELCOME_SHOW_BATTERY_LOW;
				voice_id = WINDOW_WELCOME_VOICE_BATTERY_LOW;
#if defined(GKT_CONFIG_NETWORK_ENABLE) && GKT_CONFIG_NETWORK_ENABLE
				gkt_network_message_upload(GKT_NETWORK_MESSAGE_TYPE_LOW_BATTERY);
#endif
			}
#if defined(GKT_CONFIG_BACKBOARD_CHECK_PAIRING) && GKT_CONFIG_BACKBOARD_CHECK_PAIRING
			gkt_user_amount_s amount = {0, 0};
			int retval;
			retval = gkt_user_get_amount(&amount, GKT_USER_AUTH_ADMIN, GKT_USER_TYPE_MAX);
			if (GKT_SUCCESS == retval && (0 != amount.used_nums)) {
				retval = gkt_backboard_check_pairing();
				if (GKT_SUCCESS != retval) {
					gkt_error("window_welcome: gkt_backboard_check_pairing failed, retval(%d)\n", retval);
				}
			}
#endif
#if defined(GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE) && GKT_CONFIG_DOOR_TRIAL_MODE_ENABLE
				uint32_t auth_counter = gp_window_unreset_data->trial_auth_counter;
				uint32_t auth_count_max = gp_window_unreset_data->trial_auth_count_max;
				uint32_t auth_count_min = gp_window_unreset_data->trial_auth_count_min;

				gkt_info("window_welcome: trial_auth, (max - min - counter) (%d - %d - %d)\n",
						auth_count_max, auth_count_min, auth_counter);
				if ((WINDOW_TRIAL_AUTH_MODE_PERPETUAL != gp_window_unreset_data->trial_auth_mode)
					&& ((auth_counter > auth_count_min) && (auth_counter <= auth_count_max)))
				{
					voice_id = WINDOW_WELCOME_VOICE_TRIAL_ALARM;
					gkt_window_timer_set(TIMER_ID_PLAY_TRIAL_PLEASE_UPGRADE, WINDOW_WELCOME_PLAY_TRIAL_PLEASE_UPGRADE_TIME, 0, 0);
				}
#endif
				if (GKT_WAKEUP_SRC_keypad == s_window_welcome.wakeup_resource) {
#if defined (GKT_CONFIG_KEYPAD_ENABLE) && GKT_CONFIG_KEYPAD_ENABLE	
					if (GKT_KEY_BELL == gkt_key_wakeup()) {
#if defined(GKT_CONFIG_CAT_EYE_ENABLE) && GKT_CONFIG_CAT_EYE_ENABLE
				gkt_cat_eye_status_e cat_eye_status;

				cat_eye_status = gkt_cat_eye_get_status();
				gkt_info("window_welcome: <KEY_BELL> cat_eye status(%u)\n", cat_eye_status);
				if (GKT_CAT_EYE_ST_INACTIVE == cat_eye_status)
					gkt_cat_eye_start();
				else if (GKT_CAT_EYE_ST_ACTIVE == cat_eye_status)
					window_welcome_remote_unlock_request();
#endif
					window_welcome_door_bell_reset();
					voice_id = WINDOW_WELCOME_VOICE_DOOR_BELL;
				}
#if defined(GKT_CONFIG_DOOR_LOCK_ENABLE) && GKT_CONFIG_DOOR_LOCK_ENABLE \
	&& defined(GKT_CONFIG_DOOR_LOCK_AUTOMATIC) && GKT_CONFIG_DOOR_LOCK_AUTOMATIC \
	&& GKT_KEY_DOUBLE_LOCK_ENABLE
				else if (GKT_KEY_DOUBLE_LOCK == gkt_key_wakeup()
					&& window_door_lock_body_is_normal())
				{
#if defined(GKT_CONFIG_AMBIENT_LIGHT_ENABLE) && GKT_CONFIG_AMBIENT_LIGHT_ENABLE
					gkt_ambient_light_set_state(WINDOW_AMBIENT_LIGHT_STATE_DEFAULT, 0, 0);
#endif
					gkt_window_show(WINDOW_ID_key_double_lock, 0);
					return;
				}
#endif
#endif
			}
#if defined(GKT_CONFIG_DOOR_LOCK_AUTOMATIC) && GKT_CONFIG_DOOR_LOCK_AUTOMATIC \
	&& (GKT_MODULE_LOC_FRONTBOARD == GKT_DOOR_LOCK_LOCATION)
			else if (GKT_WAKEUP_SRC_RTC == s_window_welcome.wakeup_resource) {
#if defined(GKT_CONFIG_AMBIENT_LIGHT_ENABLE) && GKT_CONFIG_AMBIENT_LIGHT_ENABLE
				gkt_ambient_light_set_state(WINDOW_AMBIENT_LIGHT_STATE_DEFAULT, 0, 0);
#endif
				gkt_window_show(WINDOW_ID_key_double_lock, 0);
				return;
			}
#endif
#if defined(GKT_CONFIG_FPS_ENABLE) && GKT_CONFIG_FPS_ENABLE
			else if (GKT_WAKEUP_SRC_fpsensor == s_window_welcome.wakeup_resource) {
				int timeout_left = 200;

				do {
					if (fps_capture_retval_global == 0) {
						window_welcome_enter_verify_window(WINDOW_VERIFY_UNLOCK_MODE_USER,
								GKT_USER_TYPE_FINGERPRINT, ~0);
						return;
					}

					timeout_left -= 10;
					if (timeout_left < 0)
						break;
					gkt_thread_sleep(10);
				} while (1);
			}
#endif
#if defined(GKT_CONFIG_RFID_ENABLE) && GKT_CONFIG_RFID_ENABLE
			else if (GKT_WAKEUP_SRC_rfid == s_window_welcome.wakeup_resource) {
				int retval, try=20;
				uint32_t rfid_data;

				do {
					if (g_card_calibrate_over == 1)
						break;

					try--;
					if (try < 0)
						break;
					gkt_thread_sleep(10);
				} while(1);

				retval = gkt_card_get_current_info(&rfid_data);
				if (retval == GKT_SUCCESS) {
					window_welcome_enter_verify_window(WINDOW_VERIFY_UNLOCK_MODE_USER,
							GKT_USER_TYPE_CARD, (uint32_t)&rfid_data);
					return;
				}
			}
#endif
#if defined(GKT_CONFIG_FACTORY_RESET_ENABLE) && GKT_CONFIG_FACTORY_RESET_ENABLE
			else if (GKT_WAKEUP_SRC_factory_reset == s_window_welcome.wakeup_resource)
				window_welcome_factory_reset_start_check(GKT_FACTORY_RESET_TYPE_INDIVIDUAL);
#endif				
#if defined(GKT_CONFIG_DOOR_TAMPER_ENABLE) && GKT_CONFIG_DOOR_TAMPER_ENABLE
			else if (GKT_WAKEUP_SRC_door_tamper == s_window_welcome.wakeup_resource)
				window_welcome_door_tamper_start_check();
#endif
#if defined(GKT_CONFIG_DOOR_LOCK_ENABLE) && GKT_CONFIG_DOOR_LOCK_ENABLE \
	&& defined(GKT_CONFIG_DOOR_LOCK_AUTOMATIC) && GKT_CONFIG_DOOR_LOCK_AUTOMATIC \
	&& defined(GKT_CONFIG_DOOR_KEY_ENABLE) && GKT_CONFIG_DOOR_KEY_ENABLE
			else if (GKT_WAKEUP_SRC_door_key == s_window_welcome.wakeup_resource) {
				gkt_door_key_e door_key = gkt_door_key_get_wakeup_key();
				gkt_info("window_welcome: wakeup door_key = %u\n", door_key);
				if (GKT_DOOR_KEY_OPEN == door_key) {
					window_welcome_enter_verify_window(WINDOW_VERIFY_UNLOCK_MODE_KEY,
							GKT_USER_TYPE_MAX, 0);
					return;
				}
				else if ((GKT_DOOR_KEY_DOUBLE_LOCK == door_key)
					&& window_door_lock_body_is_normal())
				{
#if defined(GKT_CONFIG_AMBIENT_LIGHT_ENABLE) && GKT_CONFIG_AMBIENT_LIGHT_ENABLE
					gkt_ambient_light_set_state(WINDOW_AMBIENT_LIGHT_STATE_DEFAULT, 0, 0);
#endif
					gkt_window_show(WINDOW_ID_key_double_lock, 0);
					return;
				}
#if GKT_DOOR_KEY_COMBINED_FACTORY_RESET_ENABLE
				else if (GKT_DOOR_KEY_COMBINED_FACTORY_RESET == door_key)
					window_welcome_factory_reset_start_check(GKT_FACTORY_RESET_TYPE_COMBINED);
#endif
			}
#endif
#if defined(GKT_CONFIG_AMBIENT_LIGHT_ENABLE) && GKT_CONFIG_AMBIENT_LIGHT_ENABLE
			gkt_ambient_light_set_state(WINDOW_AMBIENT_LIGHT_STATE_DEFAULT, 0, 0);
#endif
		}
		else {
			voice_id = WINDOW_WELCOME_VOICE_MAX;

			if (g_window_ram_data.factory_reset_finish) {
				g_window_ram_data.factory_reset_finish = 0;
				gkt_window_show(WINDOW_ID_initialization, 0);
				return;
			}
			else if (GKT_BATTERY_LEVEL_EMPTY == s_window_welcome.battery_level &&
				!s_window_welcome.battery_low_showed)
			{
				mask_type = WINDOW_WELCOME_MASK_BATTERY_LOW;
				show_type = WINDOW_WELCOME_SHOW_BATTERY_LOW;
				voice_id = WINDOW_WELCOME_VOICE_BATTERY_LOW;
#if defined(GKT_CONFIG_NETWORK_ENABLE) && GKT_CONFIG_NETWORK_ENABLE
				gkt_network_message_upload(GKT_NETWORK_MESSAGE_TYPE_LOW_BATTERY);
#endif
			}
		}

#if defined(GKT_CONFIG_FACTORY_INSPECT_ENABLE) && GKT_CONFIG_FACTORY_INSPECT_ENABLE
		if (((WINDOW_WELCOME_VOICE_MAX == voice_id)
			|| (WINDOW_WELCOME_VOICE_WELCOME == voice_id))
			&& !s_window_welcome.factory_inspect_complete)
		{
			voice_id = WINDOW_WELCOME_VOICE_FACTORY_INSPECT_INCOMPLETE;
		}
#endif

		gkt_key_led_control(GKT_KEY_LED_CTRL_ALL_ON, 1);
		window_key_DOUBLE_LOCK_control(1);
		window_clear_double_lock_key_wait_long_press();

#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
		if(g_window_ram_data.silent_mode == 1){
			window_welcome_mask(WINDOW_WELCOME_MASK_DEFAULT);
#if	defined(GKT_CONFIG_LIGHTING_EFFECT_EN)&&(GKT_CONFIG_LIGHTING_EFFECT_EN)
			key_open_lock_lighting_effect.lighting_effect = GKT_LIGHTING_EFFECT_OFF;
			gkt_lighting_effect_display(key_open_lock_lighting_effect);
#endif
		}
		else{
			window_welcome_mask(mask_type);
			window_welcome_play_voice(voice_id);
		}
#else
		gkt_printf("welcome: voice_id=%d\n", voice_id);
		window_welcome_mask(mask_type);
		window_welcome_show(show_type);
		window_welcome_play_voice(voice_id);
#endif
#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
		{
			int retval;
			gkt_user_amount_s amount;

			retval = gkt_user_get_amount(&amount, GKT_USER_AUTH_MAX, GKT_USER_TYPE_MAX);
			if ((GKT_SUCCESS == retval) && (amount.used_nums > 0)) {
				retval = gkt_user_get_amount(&amount, GKT_USER_AUTH_MAX, GKT_USER_TYPE_FACE_ID);
				if ((GKT_SUCCESS == retval) && (amount.used_nums > 0))
					g_window_ram_data.face_id_init_state = WINDOW_DATA_FACE_ID_STATE_SET;
				else
					g_window_ram_data.face_id_init_state = WINDOW_DATA_FACE_ID_STATE_INIT;
			}

			if(data){
				if(mask_type == WINDOW_WELCOME_MASK_BATTERY_LOW){
					s_window_welcome.battery_low_voice_paly_flag = 1;
				}
			}

			if(s_window_welcome.battery_low_voice_paly_flag == 0){
				if(gkt_face_id_is_ready()){
					window_welcome_face_id_start();
				}
			}
		}
#endif
	}
	else if(GKT_WINDOW_INACTIVE == minor_type) {
#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
		gkt_window_timer_clear(TIMER_ID_FACE_ID_RESTART_TIMEOUT);
#endif
		s_window_welcome.wakeup_resource = GKT_WAKEUP_SRC_none;
		gkt_key_led_control(GKT_KEY_LED_CTRL_ALL_ON, 0);
		window_key_DOUBLE_LOCK_control(0);
	}
}

static int window_welcome_event_handler(
				uint32_t major_type, uint32_t minor_type,
				uint32_t id, uint32_t data)
{
#if defined(GKT_CONFIG_RFID_ENABLE) && GKT_CONFIG_RFID_ENABLE
	if (g_window_ram_data.delay_unmask_card
		&& (g_window_ram_data.delay_unmask_card_ms > 0))
	{
		uint32_t time_ms = gkt_systime_ms();
		if (g_window_ram_data.delay_unmask_card_ms <= time_ms) {
			g_window_ram_data.delay_unmask_card = 0;
			g_window_ram_data.delay_unmask_card_ms = 0;

			gkt_event_unmask_single(GKT_EVENT_CARD);
		}
	}
#endif

#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
	{
		if(g_window_ram_data.silent_mode == 1){
			silence_exit_flag = 0;
		}
		if(GKT_EVENT_SYSTEM == major_type){
			if((GKT_WINDOW_SYSTEM_FACTORY_RESET == minor_type)	||\
					(GKT_WINDOW_SYSTEM_SLIDING_CLOSURE == minor_type)	||\
					(GKT_WINDOW_SYSTEM_INDOOR_BELL == minor_type)){
						flag_operation = 1;
						silence_exit_flag = 1;
			}
			else if(GKT_WINDOW_SYSTEM_DOOR == minor_type){
				if((GKT_DOOR_NOTIFY_KEY <= id) && (id <= GKT_DOOR_NOTIFY_MAGNETIC)){
					flag_operation = 1;
					silence_exit_flag = 1;
				}
			}
		}
		if((GKT_EVENT_KEY <= major_type) && (major_type < GKT_EVENT_FACE_ID)){
			flag_operation = 1;
			silence_exit_flag = 1;
		}
		if((g_window_ram_data.silent_mode == 1) && (silence_exit_flag == 1)){
			if(silence_exit_cd_cnt > 0){
				//window_welcome_show_silent_cd(WINDOW_WELCOME_SILENT_CD_CLOSE);
				g_window_ram_data.silent_mode = 0;
			}
		}
	}
#endif

	if (GKT_EVENT_WINDOW == major_type)
		window_welcome_window_event_handler(minor_type, id, data);
	else if (GKT_EVENT_TIMER == major_type)
		window_welcome_timer_event_handler(minor_type);
	else if (GKT_EVENT_VOICE == major_type)
		window_welcome_voice_event_handler(minor_type, (int)id);
	else if (GKT_EVENT_SYSTEM == major_type) 
		window_welcome_system_event_handler(minor_type, id, data);
	else if (GKT_EVENT_KEY == major_type)
		return window_welcome_key_event_handler(minor_type, (uint32_t *)data);
	else if (GKT_EVENT_FPS == major_type) {
		window_welcome_enter_verify_window(WINDOW_VERIFY_UNLOCK_MODE_USER,
			GKT_USER_TYPE_FINGERPRINT, 0);
	}
#if defined(GKT_CONFIG_RFID_ENABLE) && GKT_CONFIG_RFID_ENABLE
	else if (GKT_EVENT_CARD == major_type) {
		window_welcome_enter_verify_window(WINDOW_VERIFY_UNLOCK_MODE_USER,
			GKT_USER_TYPE_CARD, data);
	}
#endif
#if defined(GKT_CONFIG_FACE_ID_ENABLE) && GKT_CONFIG_FACE_ID_ENABLE
	else if (GKT_EVENT_FACE_ID == major_type) {
		if(minor_type == 0){//real event
			window_welcome_face_id_handle(data);
		}
		else{//virtual event

		}
	}
#endif
	return GKT_EVENT_HANDLE_COMPLETE;
}
GKT_WINDOW_DESC_DEFINE_NO_WIDGETS(welcome);

